//	Problem 057: Square root convergents

package main

import (
	"fmt"
	"math/big"
)

func p057() {
	frac := big.NewRat(2, 1)
	n, d := frac.Num(), frac.Denom()
	table := big.NewInt(0)
	two := big.NewRat(2, 1)
	var total int
	for i := 0; i < 1000; i++ {
		frac.Add(two, frac.Inv(frac))
		if len(table.Add(n, d).String()) > len(n.String()) {
			total++
		}
	}
	fmt.Println("Problem 057:", total)
}
